package cn.hpclub.server.model;

import java.io.Serializable;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.jfinal.ext.plugin.tablebind.TableBind;
import com.jfinal.plugin.activerecord.Model;

import cn.hpclub.server.constant.H5ApiConstant;

/**
 * 实体类 - 地市数据
 * 
 */
@TableBind(tableName = "cmcc_city")
public class CmccCity extends Model<CmccCity> implements Serializable{
    private static final Logger  logger           = LoggerFactory.getLogger(CmccCity.class);
    private static final long    serialVersionUID = 5108597504836776212L;
    public static final CmccCity dao              = new CmccCity();

    public static final String   REGION_ID        = "region_id";
    public static final String   REGION_NAME      = "region_name";
    public static final String   GROUP_ID         = "group_id";
    public static final String   LOGIN_NO         = "login_no";
    public static final String   REGION_ID_3      = "region_id_3";

    /**
     * @Title: findCityByCode
     * @Description:TODO
     * @param para
     * @return CmccCity
     */
    public CmccCity findCityByCode(String cityCode){
        String sql = "select * from " + H5ApiConstant.Table.CMCC_CITY + " where " + REGION_ID + "=?";
        return findFirst(sql, cityCode);
    }

    /**
     * @Title: findCityByGroupId
     * @Description:TODO
     * @param para
     * @return CmccCity
     */

    public CmccCity findCityByGroupId(String groupId){
        String sql = "select * from " + H5ApiConstant.Table.CMCC_CITY + " where " + GROUP_ID + "=?";
        return findFirst(sql, groupId);
    }

    /**
     * @Title: getRegionId3ByregionId
     * @Description:TODO
     * @param regionId
     * @return int
     */
    public CmccCity getRegionId3ByregionId(int regionId){
        return dao.findFirst("select region_id_3 from cmcc_city where region_id=?", regionId);
    }

}
